<script setup>
import { ref } from 'vue'
let toy = ref('奥特曼')
let book = ref(5)

//defineExpose宏函数 子组件需要申明将那些数据暴露给父组件
defineExpose({
    toy,
    book
})

function minuHouse(parent) {
    console.log("获取到了当前组件的爸爸", parent);
    parent.house -= 1
}
</script>
<template>
    <div id="myfather">
        <h3>我是儿子1组件</h3>
        <h3>myson1组件的玩具是:{{ toy }}</h3>
        <h3>myson1组件有:{{ book }}书</h3>
        <button @click="minuHouse($parent)">拿走父亲的一套房产</button>
    </div>
</template>
<style scoped>
#myfather {
    background-color: #8f63d6;
    padding: 10px;
    border: 1px solid rgb(176, 31, 123)
}
</style>